![]() |
PATH![]() |
![]() ![]() |
You add comments to a script to explain what the script does, you add comments. A comment is text that remains in a script after compilation but is ignored by AppleScript when the script is executed. There are two kinds of comments:
You can nest comments, that is, comments can contain other comments.
Here are some sample comments:
--end-of-line comments extend to the end of the line;
(* Use block comments for comments that occupy
more than one line *)
copy result to theCount --stores the result in theCount
(* The following subroutine, findString, searches for a string in a list of
AppleWorks word processing files *)
(* Here are examples of
--nested comments
(* another comment within a comment *)
*)
The following block comment causes an error because it is embedded in a statement.
--the following block comment is illegal
tell application "Finder"
get (* name of *) file 1 of startup disk
end tell
Because comments are not executed, you can prevent parts of scripts from being executed by putting them between comment characters. You can use this trick, known as "commenting out," to isolate problems when debugging scripts or temporarily block execution of any parts of a script that aren't yet finished. Here's an example of "commenting out" an unfinished handler:
(*
on finish()
--under construction
end
*)
If you later remove " (* " and " *) ", the handler is once again available. Handlers are described in Handlers.